package com.jw.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnBean(MinioProperties.class)
public class MinioConfiguration {

	@Autowired
	private MinioProperties minioProperties;

	/**
	 * 注入minio 客户端
	 * 
	 * @return
	 */
	@Bean
	public MinioClient minioClient() {
		return MinioClient.builder().endpoint(minioProperties.getEndpoint())
				.credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey()).build();
	}
}